/****************************************************************************
**
** Copyright (C) 2013 Ernesto Barragan <ernestus at gmail dot com>
**
** GNU General Public License Usage
** This file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
****************************************************************************/

#ifndef NUMERICINPUTDIALOG_H
#define NUMERICINPUTDIALOG_H

#include <QDialog>

namespace Ui {
class NumericInputDialog;
}

class NumericInputDialog : public QDialog
{
    Q_OBJECT

public:
    explicit NumericInputDialog(QWidget *parent = 0);
    ~NumericInputDialog();
    QByteArray value() ;

public slots:
    virtual int exec() ;
    virtual void clear() ;

protected:
    static QByteArray hexString(const QByteArray &ba, int size, bool doReverse) ;
    static void reverse(QByteArray &ba ) ;
    static QByteArray stripUnnecessaryBytes(const QByteArray &ba, int size, bool doReverse) ;

private slots:
    void on_accept8bit_clicked();
    void on_accept16bit_clicked();
    void on_accept32bit_clicked();
    void on_accept64bit_clicked();
    void on_acceptFloat_clicked();
    void on_acceptDouble_clicked();

    void on_inputValueLineEdit_textEdited(const QString &text);

    void on_bigEndianRadioButton_clicked(bool checked);

    void on_littleEndianRadioButton_clicked(bool checked);

private:
    void updateUi() ;

    Ui::NumericInputDialog *ui;
    bool m_isSigned ;
    bool m_isValidAsInteger ;
    bool m_isValidAsUnsigned ;
    bool m_isValidAsFloatingPoint ;
    quint64 m_integerValue ;
    double m_floatingPointValue ;
    //used to store the returned value
    QByteArray m_value ;
};

#endif // NUMERICINPUTDIALOG_H
